package com.longchat.controller.upload;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.longchat.domain.system.User;
import com.longchat.dto.comm.ResultInfo;
import com.longchat.service.inter.upload.IExpressService;

@Controller
@RequestMapping("/express")
public class ExpressController {
	
	private static Logger logger = LoggerFactory.getLogger(ExpressController.class);
	@Autowired
	private IExpressService expressService;
	
	/**
     * 快递费用导入
     * @param file
     * @param response
     * @param request
     * @param importType
     * @return
     * @throws IOException
     */
    @RequestMapping(value="info-import-excel", method=RequestMethod.POST,produces={"text/html;charset=UTF-8"})
    @ResponseBody
    public ResultInfo cardImport(@RequestParam("uploadFile") MultipartFile file,HttpServletResponse response,HttpServletRequest request) {
        ResultInfo rs;
        User u = new User();
        try{
            logger.error("进入号码卡密信息导入 cardImport");
            response.setContentType("text/html; charset=UTF-8");
            rs = expressService.importExpressInfoFile(file, u);
        }catch(Exception ex){
            logger.error("导入失败:{}",ex);
            return new ResultInfo(500, "导入失败！");
        }
        return rs;
    }

}
